from .base_api import BaseAPI
from ..shippypro import api_key, headers, shippypro_url
from odoo import _, api, models

key = api_key
headers = headers
url = shippypro_url


class CarriersAPI(BaseAPI):
    """ 承运商接口 """

    @classmethod
    def get_carriers(cls) -> dict:
        return super().post('GetCarriers')

    @classmethod
    def get_carriers_options(cls, carrier_name: str,
                             carrier_id: int,
                             country: str,
                             postal_code: str,
                             city: str
                             ) -> dict:
        """
        获取某个承运商的可用增值服务及价格
        :param carrier_name: 承运商名称
        :param carrier_id: 承运商ID(shippypro提供)
        :param country: 国家名称
        :param city: 城市名称(市一级)
        :param postal_code: 邮政编码
        """
       
        
        return super().post('GetCarrierOptions', {
                "CarrierName": carrier_name,
                "CarrierID": int(carrier_id),
                "to_address": {
                    "city": city,
                    "zip": postal_code,
                    "country": country
                }
            })
        

    @classmethod
    def get_carrier_packages_type(cls) -> dict:
        """
        获取所有承运商的所有可用包裹类型
        """
        return super().post('GetCarrierPackagesTypes')

